Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Solution #47

wants to merge 2 commits into from

Conversation

arsen-arutiunov
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your hard work on this project! 🎉 While your code is well-structured and meets many of the task requirements, there are a few critical issues that need to be addressed before we can approve the pull request.

  1. Missing Movie Deletion Endpoint: The task requires an implementation for the movie deletion endpoint in the routes/movies.py file. This is crucial for meeting the core requirements of the task. Please add this endpoint to handle DELETE requests to /movies/{movie_id}/.

  2. Port Conflict in docker-compose.yml: The db service is set to use port 5433 on the host. Ensure this port is not already in use to avoid conflicts. If it is, consider changing the host port.

  3. Error Handling in Database Operations: It's important to add error handling around db.commit() operations in your API endpoints to catch potential database errors. This will improve the robustness of your application.

  4. Safe Access in Pydantic Validator: In the convert_null_to_string root validator, use country.get('name') to safely access the 'name' key and avoid potential KeyError.

Once these issues are addressed, your code will be in great shape! Keep up the excellent work and don't hesitate to reach out if you have any questions. 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

🔄 Fix the issues, commit the changes, and then re-request my review using the Re-request review button in the Reviewers tab.

@@ -5,7 +5,7 @@ services:
env_file:
- .env
ports:
- "5432:5432"
- "5433:5432"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The port mapping for the db service is set to 5433:5432. Ensure that port 5433 is not already in use on your host machine to avoid conflicts. If it is, consider using a different host port.

languages=languages
)
db.add(new_movie)
db.commit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding error handling around the db.commit() operation to catch potential database errors. This will help in diagnosing issues if the commit fails.

if movie_update.revenue is not None:
movie.revenue = movie_update.revenue

db.commit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the create operation, consider adding error handling around the db.commit() operation to catch potential database errors during the update process.

Comment on lines +110 to +111
if not country["name"]:
country["name"] = "null"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convert_null_to_string root validator assumes that the 'country' dictionary will always have a 'name' key. Consider using country.get('name') to safely access the 'name' key and avoid potential KeyErrors if the 'country' data is not structured as expected.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Great job on addressing the previous issues and improving your code! 🎉 Here are some important points from the review:

  1. Movie Deletion Endpoint: You've successfully implemented the movie deletion endpoint in the routes/movies.py file. It handles DELETE requests correctly and meets the task requirements.

  2. Port Configuration in docker-compose.yml: Although the docker-compose.yml file wasn't provided, ensure that the host port 5433 for the db service is not in conflict with other services. Consider changing it if necessary.

  3. Error Handling in Database Operations: You've added error handling around database operations, which is a great practice. The safe_commit function is a good addition to manage potential database errors.

  4. Safe Access in Pydantic Validator: You've improved the convert_null_to_string root validator by using country.get('name') to safely access the 'name' key, preventing potential KeyError.

Overall, your solution is on the right track! 🚀 While there are a few issues to address, such as ensuring port availability and refining the Pydantic validator, these are learning opportunities. Keep up the great work and continue refining your skills. Remember, addressing critical issues will help you avoid similar problems in the future. Keep pushing forward and learning from these experiences! 😊

✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨

@@ -5,7 +5,7 @@ services:
env_file:
- .env
ports:
- "5432:5432"
- "5433:5432"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The db service is configured to use port 5433 on the host. Ensure this port is not already in use to avoid conflicts. If it is, consider changing the host port.

Comment on lines +108 to +111
def convert_null_to_string(cls, values):
country = values.get("country")
if not country["name"]:
country["name"] = "null"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the convert_null_to_string root validator, use country.get('name') to safely access the 'name' key and avoid potential KeyError. This ensures that the code does not break if 'name' is not present in the country dictionary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants